/**     
 * @{#} LifeCycle.java Create on 2011-7-21 下午10:20:03     
 *     
 * Copyright (c) 2011 by xiaofeng.zhouxf     
 */
package com.sefer.memcached.lifecycle;

import com.sefer.memcached.exception.ClientException;

/**
 * <pre>
 * Common interface for connect component life cycle methods. Memcached client
 * connect component should implement this interface.
 * 
 * State run below:
 * 
 *       new(new method()) -> connect_before -> connecting -> connect_success 
 *                                               |               |                                 
 *                                               |               |                                 
 *                                              \|/             \|/                                
 *                                           connect_fail    wating_for_call <---------------------|
 *                                               |               |                                 |
 *                                               |               |                                 |
 *                                               |               |exception                        |
 *                                              \|/              |                                 |
 *         stoping(stop method)--------------> stop <-------------                                 |
 *                                              /|\              |                                 |
 *                                               |              \|/                                |
 *                                           call_fail<------ before_call(invoke command method)   |
 *                                              /|\              |                                 |
 *                                               |               |                                 |
 *                                               |               |                                 |
 *                                               |              \|/                                |
 *                                               ---------- calling(connect to server)             |
 *                                                               |                                 |
 *                                                               |                         auto    |
 *                                                           called_finished ----------------------
 * 
 * </pre>
 * 
 * @see
 * @author <a href="mailto:xiaofeng.zhouxf83@gmail.com">xiaofeng.zhouxf</a>
 * @version 1.0
 */
public interface LifeCycle {
	// states
	String NEW = "new";
	String STATING = "stating";
	String STATED = "stated";
	String CALLING = "calling";
	String CALL_FAIL = "call_fail";
	String CALLED_SUCCESS = "called_success";
	String STOPING = "stoping";
	String STOP = "stop";

	boolean start() throws ClientException;

	boolean stop() throws ClientException;

	String getState();

	void setState(String state);
}
